<template>
	<view class="tabbar-container">
		<block>
			<view class="tabbar-item" v-for="(item, index) in tabbarList" :class="[item.centerItem ? ' center-item' : '']" @click="changeItem(item)">
				<view class="item-top" :class="{'extrude':item.id == 1}"><image :src="currentItem == item.id ? item.selectIcon : item.icon"></image></view>
				<view class="item-bottom" :class="[currentItem == item.id ? 'item-active' : '']">
					<text>{{ item.text }}</text>
				</view>
			</view>
		</block>
	</view>
</template>
 
<script>
export default {
	props: {
		currentPage: {
			type: Number,
			default: 0
		}
	},
	data() {
		return {
			currentItem: 0,
			tabbarList: [
				{
					id: 0,
					path: '/pages/index/index',
					icon: '/static/index.png',
					selectIcon: '/static/index-activate.png',
					text: '首页',
					centerItem: false
				},
				{
					id: 1,
					path: '',
					icon: '/static/sweep.png',
					selectIcon: '/static/sweep.png',
					text: '',
					centerItem: false
				},
				{
					id: 2,
					path: '/pages/my/my',
					icon: '/static/my.png',
					selectIcon: '/static/my-activate.png',
					text: '我的',
					centerItem: false
				}
			]
		};
	},
	mounted() {
		this.currentItem = this.currentPage;
		uni.hideTabBar();
	},
	methods: {
		changeItem(item) {
			if(item.id == 1){
				return
			}
			let _this = this;
			uni.switchTab({
				url: item.path
			});
			
		}
	}
};
</script>
<style>
	.extrude {
		width: 100rpx !important;
		height: 100rpx !important;
		position: relative;
		top: -10rpx !important;
	}
view {
	/* padding: 0;
	margin: 0;
	box-sizing: border-box; */
}
.tabbar-container {
	position: fixed;
	bottom: 0;
	left: 0;
	width: 100%;
	height: 150rpx;
	/* box-shadow: 0 0 3px #e1e1e1; */
	display: flex;
	align-items: center;
	padding: 5rpx;
	/* padding: 5rpx 0 30rpx 5rpx; */
	font-weight: 500;
	font-size: 20rpx;
	color: #A4A9B7;
	/* background-color: #ffffff; */
	background-image: url('../static/tabtar-bac.png');
	background-size:100%;
	 /* background-size: cover; */
}
.tabbar-container .tabbar-item {
	width: 33.333%;
	height: 100rpx;
	display: flex;
	flex-direction: column;
	justify-content: center;
	align-items: center;
	text-align: center;
	margin-top: 30rpx;
}
.tabbar-container .item-active {
	color: #4BC264;
}
.tabbar-container .center-item {
	display: block;
	position: relative;
}
.tabbar-container .tabbar-item .item-top {
	width: 48rpx;
	height: 48rpx;
	/* padding: 10rpx; */
}
.tabbar-container .center-item .item-top {
	flex-shrink: 0;
	width: 80rpx;
	height: 80rpx;
	position: absolute;
	/* top: -20rpx; */
	left: calc(50% - 40rpx);
	border-radius: 50%;
	box-shadow: 0 0 5px #999;
	background-color: #ffffff;
}
.tabbar-container .tabbar-item .item-top image {
	width: 100%;
	height: 100%;
}
.tabbar-container .tabbar-item .item-bottom {
	/* font-size: 28rpx; */
	width: 100%;
}
.tabbar-container .center-item .item-bottom {
	position: absolute;
	bottom: 15rpx;
	/* bottom: 20rpx; */
}
</style>